import 'package:flutter/material.dart';
import 'package:photoxia/compant/Kbutton.dart';

import '../compant/Appcolor.dart';
import '../compant/signTextField.dart';

import 'SignUpToWin.dart';

class SignUpTo extends StatefulWidget {
  const SignUpTo({super.key});

  @override
  State<SignUpTo> createState() => _SignUpToState();
}

class _SignUpToState extends State<SignUpTo> {
  late final PageController controller;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = PageController();
  }

  double value = 0.25;
  double count = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Padding(
        padding: const EdgeInsets.all(30.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            RichText(
                text: TextSpan(
              style: TextStyle(color: textColor, fontSize: 26),
              text: 'Sign up to',
              children: [
                TextSpan(text: ' PhotoXia', style: TextStyle(color: buttomBgc)),
              ],
            )),
            const SizedBox(
              width: double.infinity,
            ),
            Slider(
              value: value,
              onChanged: (value) {},
              activeColor: SliderColor,
              inactiveColor: const Color(0xffE6E6E6),
              thumbColor: const Color(0xffFF876B),
            ),
            Expanded(
              child: PageView(
                controller: controller,
                children: [
                  SignUpTopage1(),
                  SignUpTopage1(),
                  SignUpTopage1(),
                ],
              ),
            ),
            const SizedBox(
              height: 60,
            ),
            Kbutton(
                ontap: () {
                  setState(() {
                    count++;
                    value += 0.25;
                    if (count == 3) {
                      count = 0;
                      value = 0.25;
                      Navigator.push(context,
                          MaterialPageRoute(builder: (BuildContext context) {
                        return const SignUpToWin();
                      }));
                    }
                    controller.jumpTo(count);
                  });
                },
                text: 'Next'),
            const SizedBox(
              height: 100,
            ),
          ],
        ),
      ),
    );
  }
}

class SignUpTopage1 extends StatelessWidget {
  const SignUpTopage1({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Your personal info',
          style: TextStyle(color: textColor2),
        ),
        const signTextField(
          text: 'Your Name',
        ),
        const signTextField(
          text: 'Email',
        ),
        const signTextField(
          text: 'Phone Number',
        ),
        const signTextField(
          text: 'Location',
        ),
        Text(
          'Date of Birth',
          style: TextStyle(color: textGaryColor, fontSize: 16),
        ),
        Container(
          height: 60,
          padding: EdgeInsets.all(15),
          decoration: BoxDecoration(
              border: Border.all(color: textGaryColor),
              borderRadius: BorderRadius.circular(10)),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Text(
                'Month',
                style: TextStyle(color: textGaryColor),
              ),
              Container(
                height: 20,
                width: 2,
                color: textGaryColor,
              ),
              Text(
                'Day',
                style: TextStyle(color: textGaryColor),
              ),
              Container(
                height: 20,
                width: 2,
                color: textGaryColor,
              ),
              Text(
                'Year',
                style: TextStyle(color: textGaryColor),
              ),
            ],
          ),
        )
      ],
    );
  }
}
